package domain

import (
	"gorm.io/gorm"
	"time"
)

type BaseModel struct {
	ID        int32     `gorm:"primary_key;AUTO_INCREMENT"`
	CreatedAt time.Time `gorm:"column:add_time"`
	UpdatedAt time.Time `gorm:"column:update_time"`
	DeletedAt gorm.DeletedAt
	IsDeleted bool `gorm:"column:is_deleted"`
}

// User
/**
1. 密文
2. 密文不可反解
2.1 对称加密
2.2 非对称加密
2.3 md5 信息摘要算法
密码如果不可反解,用户找回密码
*/
type User struct {
	BaseModel
	Mobile   string     `gorm:"index:idx_mobile;unique;type:varchar(11);not null"`
	PassWord string     `gorm:"column:password;type:varchar(100);not null"`
	NickName string     `gorm:"type:varchar(20) comment '昵称'"`
	Birthday *time.Time `gorm:"type:datetime comment '生日'"`
	Gender   string     `gorm:"column:gender;default:male;type:varchar(6) comment 'female 女,male 男'"`
	Role     int        `gorm:"column:role;default:1;not null;type:int comment '1 普通用户,2 表示管理员'"`
}
